#!/usr/bin/env bash
# htpasswd

if [[ -z "${c_htpasswd}" ]]; then
    f_info 'htpasswd: not install';
    echo > /dev/null;  return;
fi;

f_wait 'htpasswd: install';

f_inst 'htpasswd' 'apache2-utils';
dir='/home/www/conf/auth';

if [[ ! -d "${dir}" ]]; then
    mkdir -p "${dir}" f_fail 'htpasswd: mkdir';
    f_mode '/home/www/conf' '700' '700' 'www:www';
fi;

cat "${RUN}/file/htpasswd-create.sh" > "${dir}/create.sh" \
    || f_fail 'htpasswd: create create.sh';
f_mode "${dir}/create.sh" '755' '-' 'www:www' || f_fail 'nginx: chmod create.sh';
